package servlet.zhouchao;

import service.GoodsService;
import service.impl.GoodsServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet(value = "/DeleteGoodsServlet")
public class DeleteGoodsServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
       doGet(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        GoodsService goodsService=new GoodsServiceImpl();
        String goId=request.getParameter("goId");
        int i=goodsService.delGoods(Integer.parseInt(goId));
        if(i>0){
            request.getRequestDispatcher("GoodsPageBeanListServlet").forward(request,response);
        }
        else{
            response.getWriter().print("删除失败");
        }
    }
}
